package demisemapping;

import java.util.ArrayList;

public class PixelSequence implements Comparable {
    ArrayList<Location> a = new ArrayList<Location>(); // stored j,i,k
    
    public PixelSequence() {
        
    }
    
    public PixelSequence(String s) {
        String[] arr = s.split(" ");
        for (int i=0;i<arr.length;i++) {
            Location loc = new Location(arr[i]);
            a.add(loc);
        }
    }
    
    public PixelSequence(Location p, Location q, Location r) {
        a.add(p);
        a.add(q);
        a.add(r);
    }
    
    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        for (int i=0;i<a.size();i++) {
            sb.append((i>0?" ":"")+a.get(i));
        }
        return sb.toString();
    }
    
    public int compareTo(Object obj) {
        assert(obj instanceof PixelSequence);
        ArrayList<Location> o = ((PixelSequence) obj).a;
        if (a.size() < o.size()) return -1;
        if (a.size() > o.size()) return 1;
        for (int i=0;i<a.size();i++) {
            int cmp = a.get(i).compareTo(o.get(i));
            if (cmp != 0) return cmp;
        }
        return 0;
    }
    
}
